<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="keyword" content="">

    <title>项目列表-工程巡查管理</title>

    <!-- Bootstrap core CSS -->
    <link href="__PUBLIC__/css/bootstrap.min.css" rel="stylesheet">
    <link href="__PUBLIC__/css/bootstrap-reset.css" rel="stylesheet">
    <!--external css-->
    <link href="__PUBLIC__/assets/font-awesome/css/font-awesome.css" rel="stylesheet" />
    <!-- Custom styles for this template -->
    <link href="__PUBLIC__/css/style.css" rel="stylesheet">
    <link href="__PUBLIC__/css/style-responsive.css" rel="stylesheet" />
    
    <!-- new styles-->
      <link href="__PUBLIC__/css/xxxstyle.css" rel="stylesheet" />
      
      <link rel="stylesheet" type="text/css" href="__PUBLIC__/assets/bootstrap-datepicker/css/datepicker.css" />
      <link rel="stylesheet" type="text/css" href="__PUBLIC__/assets/bootstrap-datetimepicker/css/datetimepicker.css" />
      <link rel="stylesheet" type="text/css" href="__PUBLIC__/assets/jquery-multi-select/css/multi-select.css" />
      <!--new dynamic table-->
      <link href="__PUBLIC__/assets/advanced-datatable/media/css/demo_page.css" rel="stylesheet" />
      <link href="__PUBLIC__/assets/advanced-datatable/media/css/demo_table.css" rel="stylesheet" />
      <link rel="stylesheet" href="__PUBLIC__/assets/data-tables/DT_bootstrap.css" />

      <!-- HTML5 shim and Respond.js IE8 support of HTML5 tooltipss and media queries -->
    <!--[if lt IE 9]>
      <script src="__PUBLIC__/js/html5shiv.js"></script>
      <script src="__PUBLIC__/js/respond.min.js"></script>
    <![endif]-->
  </head>

  <body>

  <section id="container">
      <!--main content start-->
      <section id="main-content">
          <section class="wrapper">
              <div class="row">
                  <div class="col-lg-12">
                      <section class="panel">
                          <header class="panel-heading tab-bg-dark-navy-blue ">
                              <ul class="nav nav-tabs">
                                  <li class="active">
                                      <a data-toggle="tab" onclick="ajaxmember(0,1)">我负责的项目</a>
                                  </li>
                                  <li class="">
                                      <a data-toggle="tab" onclick="ajaxmember(0,2);">我参与的项目</a>
                                  </li>
                                    <?php if($_SESSION['role']==1):?>
                                  <li class="">
                                      <a data-toggle="tab" onclick="ajaxmember(0,3);">所有项目</a>
                                  </li>
                                   <?php endif?>
                              </ul>
                          </header>
                          <div class="panel-body">

                              <div id="ajaxmember"></div>

                              <div class="task-log">
                                  <div class="adv-btn">
                                      <button class="btn btn-submit" data-toggle="modal" href="#CreatProjectModal">创建项目</button>                               
                                  </div>
                              </div>
                          </div>
                      </section>
                  </div>
              </div>
          	  <!-- Modal 创建项目 -->
              <div class="modal fade" id="CreatProjectModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                  <div class="modal-dialog bigmodal">
                    <div class="modal-content">
                        <div class="modal-header">
                          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                          <h4 class="modal-title">创建项目</h4>
                        </div>
                        <div class="modal-body">
                            <div class="form-group">
                                <label class="col-sm-1-8 control-label">项目名称</label>
                                <div class="col-sm-7-8">
                                    <input type="text" class="form-control" name="name">
                                </div>
                            </div>

                            <div class="form-group-nohidden">
                                <label class="col-sm-15 control-label">项目代码</label>
                                <div class="col-sm-45">
                                    <input type="text" class="form-control" placeholder="字母加数字" name="code" maxlength="5" onKeyUp="value=value.replace(/[\W]/g,'')">
                                </div>
                                <label class="col-sm-15 control-label">项目负责人</label>
                                <div class="col-sm-45">
                                    <select id="total_ren" class="selectpicker" data-live-search="true">
                                        <option>请选择</option>
                                        <foreach name="user" item="v" key="k">
                                            <optgroup label="{$v.cat_name}">
                                                <foreach name="v.user" item="vv" key="kk">
                                                    <option value ="{$vv.admin_id}">{$vv.name}({$vv['post']})</option>
                                                </foreach>
                                            </optgroup>
                                        </foreach>
                                    </select>
                                </div>
                                <!-- <label class="col-sm-15 control-label">项目进度</label>
                                <div class="col-sm-45">
                                    <select class="form-control" id="speed">
                                        <option sid="1">未开始</option>
                                        <option sid="2">进行中</option>
                                        <option sid="3">推迟</option>
                                        <option sid="4">完成验收</option>
                                        <option sid="5">驳回</option>
                                        <option sid="6">中断</option>
                                    </select>                                          
                                    <span class="caret"></span>
                                </div> -->
                            </div>

                            <div class="form-group">
                                <label class="col-sm-15 control-label">项目地址</label>
                                <div class="col-sm-45">
                                    <input type="text" class="form-control" name="paddress">
                                </div>
                                <label class="col-sm-15 control-label">标段号</label>
                                <div class="col-sm-45">
                                    <input type="text" class="form-control" name="blockname">
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <label class="col-sm-15 control-label">项目开始日期</label>
                                <div class="col-sm-45">
                                    <div class="input-group date form_datetime-component">
                                      <input type="text" class="form-control" readonly="" name="p_start"/>
                                      <span class="input-group-btn">
                                        <button type="button" class="btn btn-calender date-set"><i class="icon-calendar"></i></button>
                                      </span>
                                    </div>
                                </div>
                                <label class="col-sm-15 control-label">项目截止日期</label>
                                <div class="col-sm-45">
                                  <div class="input-group date form_datetime-component">
                                    <input type="text" class="form-control" readonly="" name="p_stop"/>
                                    <span class="input-group-btn">
                                      <button type="button" class="btn btn-calender date-set"><i class="icon-calendar"></i></button>
                                    </span>
                                </div>
                                </div>
                            </div> 
                            <div class="form-group">
                                <label class="col-sm-1-8 control-label">概况详情</label>
                                <div class="col-sm-7-8">
                                    <textarea class="form-control error" id="" name="profile" rows="5" required=""></textarea>
                                </div>
                            </div>  
                            <div class="form-group">
                                <label class="col-sm-1-8 control-label">阶段性成果</label>
                                <div class="col-sm-7-8">
                                    <textarea class="form-control error" id="" name="stage" rows="5" required=""></textarea>
                                </div>
                            </div>                   
                        </div>
                        <div class="modal-footer">
                            <button data-dismiss="modal" class="btn btn-default" type="button">取消</button>
                            <button class="btn btn-submit" type="submit" onclick="establish()">创建</button>
                        </div>
                    </div>
                  </div>
              </div>
              <!-- modal -->
          </section>
      </section>
      <!--main content end-->
      
      <!-- Modal 设置人员 -->
      		<div class="modal fade" id="spModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
      			
      		</div>
      <!-- modal -->
  </section>

    <!-- js placed at the end of the document so the pages load faster -->
    <script src="__PUBLIC__/js/jquery.js"></script>
    <script src="__PUBLIC__/js/jquery-1.8.3.min.js"></script>
    <script src="__PUBLIC__/js/bootstrap.min.js"></script>
    <script src="__PUBLIC__/js/jquery.scrollTo.min.js"></script>
    <script src="__PUBLIC__/js/jquery.nicescroll.js" type="text/javascript"></script>
    <script src="__PUBLIC__/js/jquery.customSelect.min.js" ></script>

    <!--common script for all pages-->
    <script src="__PUBLIC__/js/common-scripts.js"></script>

      <!--new script for this page only-->
       <script src="__PUBLIC__/js/bootstrap-select.js"></script>

      <!--dynamic table initialization -->
      <script src="__PUBLIC__/js/jquery-migrate-1.2.1.min.js"></script>
      <script class="include" type="text/javascript" src="__PUBLIC__/js/jquery.dcjqaccordion.2.7.js"></script>
      <script src="__PUBLIC__/js/respond.min.js" ></script>
      
	      <!--Dispatch staff-->
	  <script type="text/javascript" src="__PUBLIC__/assets/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
	
	  <script type="text/javascript" src="__PUBLIC__/assets/bootstrap-datetimepicker/js/bootstrap-datetimepicker.js"></script>
	  <script type="text/javascript" src="__PUBLIC__/assets/bootstrap-colorpicker/js/bootstrap-colorpicker.js"></script>
	  <script type="text/javascript" src="__PUBLIC__/assets/bootstrap-timepicker/js/bootstrap-timepicker.js"></script>
    
	  <script type="text/javascript" src="__PUBLIC__/assets/jquery-multi-select/js/jquery.multi-select.js"></script>
	  <script type="text/javascript" src="__PUBLIC__/assets/jquery-multi-select/js/jquery.quicksearch.js"></script>
	
	  <script src="__PUBLIC__/js/advanced-form-components.js"></script>
	  <script src="__PUBLIC__/js/form-component.js"></script>
      <script type="text/javascript" src="__PUBLIC__/js/layer/layer.js"></script>
      
  <script>
      $(function(){
          //custom select box
          $('select.styled').customSelect();
          
      });
      
      $(document).ready(function(){
          ajaxmember();
      });

      // ajax 抓取页面
      function ajaxmember(speed=0,join=1){
              $.ajax({
                  type : "POST",
                  url:'__URL__/ajaxmember',
                  data : {speed:speed,join:join},
                  success: function(data){
                      $("#ajaxmember").html('');
                      $("#ajaxmember").append(data);
                  }
              });
      }
      
      //创建项目
      function establish(){
    	  var name = $("input[name='name']").val();
    	  var code = $("input[name='code']").val();
    	  var paddress = $("input[name='paddress']").val();
    	  var blockname = $("input[name='blockname']").val();
    	  var p_start = $("input[name='p_start']").val();
    	  var p_stop = $("input[name='p_stop']").val();
    	 // var speed = $('#speed option:selected').attr('sid');
    	  var total_ren = $('#total_ren option:selected').val();
    	  var stage =  $("textarea[name='stage']").val();
    	  var profile =  $("textarea[name='profile']").val();
    	  if(name==''){
    		  layer.msg('项目名不能为空',{icon:2});
    		  return;
    	  }
    	  if(code==''){
    		  layer.msg('项目代码不能为空',{icon:2});
    		  return;
    	  }
    	  if(paddress=='' || blockname==''){
    		  layer.msg('项目地址或地块有空',{icon:2});
    		  return;
    	  }
    	  if(total_ren=='请选择'){
    		  layer.msg('项目负责人不能为空',{icon:2});
    		  return;
    	  }
    	  if(p_start=='' || p_stop==''){
    		  layer.msg('项目日期不能为空',{icon:2});
    		  return;
    	  }
    	  if(profile==''){
    		  layer.msg('概况详情不能为空',{icon:2});
    		  return;
    	  }
    	  if(stage==''){
    		  layer.msg('阶段成果不能为空',{icon:2});
    		  return;
    	  }
    	  
    		 $.ajax({
 		 		type : 'post',
 		 		url : '__URL__/saveproduct',
 		 		data : {name:name,code:code,paddress:paddress,blockname:blockname,p_start:p_start,p_stop:p_stop,total_ren:total_ren,stage:stage,profile:profile},
 		 		dataType : 'json',
 		 		success : function(res){
 		 			 if(res.status==0){
							layer.alert(res.info, {icon: 2});
							return;
						 }
 		 			 if(!res.errNo){
 		 				 layer.msg(res.msg,{icon:1});
 		 				 setTimeout("location.reload()",2000);
 			          }else{
 			        	 layer.msg(res.msg,{icon:2});
 			          }
 		 		}
 		     })
      }
      //项目进度下拉
      function speed(o){
    	  var speed = o.value;
    	  ajaxmember(speed);
      }
      
      //ajax设置人员
      function setpm(o,total){
    	  $.ajax({
		 		type : 'post',
		 		url : '__URL__/ajaxsetpm',
		 		data : {id:o,total:total},
		 		//dataType : 'json',
		 		success : function(res){
		 			if(res.status==0){
						layer.alert(res.info, {icon: 2});
						return;
					 }
		 			 $("#spModal").html('');
                     $("#spModal").append(res);
                     $("#spModal").modal('show');
		 		}
		     })
      }
      
      //保存设置人员
      function savesetpm(aid,status){
    	  var engs = $("input[name*='eng']");
    	 // var project_offices = $("input[name*='project_office']");
    	//  var supervisors = $("input[name*='supervisor']");
    	 // var units = $("input[name*='unit']");
    	  if(engs.is(":checked")){
              var eng = [];
              for(var k in engs){
                  if(engs[k].checked)
                      eng.push(engs[k].value);
              }
          }
    	 if(eng==undefined){
    		 layer.msg('请勾选项目人员',{icon:2});
   		     return;
    	 }
   	  $.ajax({
	 		type : 'post',
	 		url : '__URL__/savesetpm',
	 		data : {eng:eng,id:aid,status:status},
	 		dataType : 'json',
	 		success : function(res){
	 			 if(res.status==0){
						layer.alert(res.info, {icon: 2});
						return;
					 }
	 			 if(!res.errNo){
	 				 $("#spModal").modal('hide');
	 				 layer.msg(res.msg,{icon:1});
		          }else{
		        	 layer.msg(res.msg,{icon:2});
		          }
	 		}
	     })
      }
  </script>
  </body>
</html>
